Space Invaders
Earth is being invaded by martians. Here's a description of the
Martian fleet:
- The Martians have some spaceships.
- Each spaceship is either a mother ship or a drone.
- A mother ship has a name, which is a String, a crew, which is a
list of Martians, and a possibly-empty set of daughter ships, each
of which is a spaceship.
- When we say the fleet of a spaceship, we mean her daughter
ships and all their fleets.
- A Martian has a name, which is a string, and some other
attributes, which are unspecified.
Write functions to accomplish the following tasks. For each
function, draw its call graph, and write a halting measure. Be prepared
to explain why your halting measure decreases around every cycle in
the graph.
- Given a spaceship, is there a Martian named "Mork" in its
crew?
- Given a spaceship, is there a Martian named "Mork" in its own
crew or in the crew of one of its daughter ships?
- Given a spaceship, how many Martians named "Mork" are in the
crew of either the spaceship or its fleet?
- Given a spaceship, return another spaceship just like the
original, except that all of its daughters that are drones have been
removed.
- Given a spaceship, return another spaceship just like the
original, except that all of the drones in its fleet have been removed.
- Given a spaceship, return another spaceship just like the
original, except that all of its daughters who have a crewmember
named "Mork" have been removed. When a daughter is removed from the
fleet, so are all its daughters and their fleets.
- Given a spaceship, return another spaceship just like the
original, except that every ship in its fleet who has a crewmember
named "Mork" has been removed. When a ship is removed from the
fleet, so are all its daughters and their fleets.
Last modified: Tue Oct 18 12:16:23 Eastern Daylight Time 2016